<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!-- 顶部栏 -->
<div class="container">
	<c:choose>
		<c:when test="${not empty sessionScope.user}">
			<div class="pull-right">
				欢迎&nbsp;<a href="user.jsp" class="btn btn-warning btn-xs">${user.realname}</a>&nbsp;<a href="user.jsp?upload=1"
					class="btn btn-success btn-xs">发布二手</a>&nbsp;
				<button type="button" onclick="loginOut()" class="btn btn-danger btn-xs">退出</button>
			</div>
			<script type="text/javascript">
				function loginOut() {
					var r = confirm("您确定要退出么？")
					if (r == true) {
						window.location.href = "index/user_i_loginOut.do";
					}
				}
			</script>
		</c:when>
		<c:otherwise>
			<div class="modal fade" id="loginDlg" tabindex="-1" role="dialog" aria-labelledby="loginModalLabel"
				aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
							<h4 class="modal-title" id="loginModalLabel">
								<strong>用户登录</strong>
							</h4>
						</div>
						<form action="index/user_i_login.do" method="post">
							<div class="modal-body">
								<div class="input-group">
									<span class="input-group-addon">校园卡号：</span> <input type="text" class="form-control" name="uid"
										placeholder="请输入卡号" required>
								</div>
								<br />

								<div class="input-group">
									<span class="input-group-addon">服务密码：</span> <input type="password" class="form-control" name="pwd"
										placeholder="请输入密码" required>
								</div>
								<br />

								<div class="input-group">
									<span class="input-group-addon"><img src="index/getImage.do"
										onclick="this.src='index/getImage.do?'+ Math.random()" title="点击图片刷新验证码" /></span> <input type="text"
										name="code" class="form-control" placeholder="请输入4位验证码" required>
								</div>
							</div>
							<div class="modal-footer">
								<button type="submit" class="btn btn-primary">登录</button>
								<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
							</div>
						</form>
					</div>
				</div>
			</div>
			<div class="modal fade" id="regDlg" tabindex="-1" role="dialog" aria-labelledby="loginModalLabel"
				aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
							<h4 class="modal-title" id="loginModalLabel">
								<strong>用户注册</strong>
							</h4>
						</div>
						<form action="index/user_i_reg.do" method="post" id="userRegDlgForm">
							<div class="modal-body">
								<div class="form-group input-group">
									<span class="input-group-addon">校园卡号：</span> <input name="uid" type="text" class="form-control"
										placeholder="请输入校园卡号">
								</div>
								<br />
								<div class="form-group input-group">
									<span class="input-group-addon">真实姓名：</span> <input name="realname" type="text" class="form-control"
										placeholder="请输入昵称(最好真实姓名)">
								</div>
								<br />
								<div class="form-group input-group">
									<span class="input-group-addon">服务密码：</span> <input name="pwd" type="password" class="form-control"
										placeholder="请输入密码">
								</div>
								<br />
								<div class="form-group input-group">
									<span class="input-group-addon">重复密码：</span> <input name="repwd" type="password" class="form-control"
										placeholder="重复输入密码">
								</div>
								<br />
							</div>
							<div class="modal-footer">
								<button type="submit" class="btn btn-primary">注册</button>
								<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
							</div>
						</form>
					</div>
				</div>
			</div>
			<script>
				showLoginDlg = function() {
					$('#loginDlg').modal('show');
				};
				$('#userRegDlgForm').bootstrapValidator({
					message : '该项为必输项',
					feedbackIcons : {
						valid : 'glyphicon glyphicon-ok',
						invalid : 'glyphicon glyphicon-remove',
						validating : 'glyphicon glyphicon-refresh'
					},
					fields : {
						uid : {
							validators : {
								notEmpty : {},
								regexp : {
									regexp : /^[0-9]+$/,
									message : '请输入10位的卡号'
								},
								stringLength : {
									min : 10,
									max : 11
								}
							}
						},
						realname : {
							validators : {
								notEmpty : {},
								stringLength : {
									min : 1,
									max : 20
								}
							}
						},
						pwd : {
							validators : {
								notEmpty : {},
								different : {
									field : 'realname',
									message : '卡号与密码不能相同'
								}
							}
						},
						repwd : {
							validators : {
								notEmpty : {},
								identical : {
									field : 'pwd',
									message : '两次密码不相同'
								}
							}
						}
					}
				});
			</script>
			<button type="button" data-toggle="modal" data-target="#regDlg" class="btn btn-warning btn-xs pull-right">注册</button>
			<button type="button" data-toggle="modal" data-target="#loginDlg" class="btn btn-success btn-xs pull-right">登录</button>
		</c:otherwise>
	</c:choose>
</div>

<!-- head end -->